<?php

/**
 * This is the model class for table "xyh_alumni_user".
 *
 * The followings are the available columns in table 'xyh_alumni_user':
 * @property string $id
 * @property string $alumni_id
 * @property string $username
 * @property string $password
 * @property string $ctime
 * @property string $status
 * @property string $is_del
 */
class AlumniUser extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return AlumniUser the static model class
	 */
           public $password_repeat;
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'xyh_alumni_user';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('alumni_id, ctime', 'length', 'max'=>10),
			array('username', 'length', 'max'=>50),
                        array('username','required','message'=>'请填写用户名!'),
                        array('password','required','message'=>'请填写密码!'),
                        array('password_repeat','required','message'=>'请填写密码!', 'on' => 'add'),
                        
                        array('password_repeat', 'compare', 'compareAttribute'=>'password','message'=>'密码不一致！','on'=>'add'),
                    
			array('password', 'length', 'max'=>128),
			array('status, is_del', 'length', 'max'=>1),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, alumni_id, username, password, ctime, status, is_del', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'alumni_id' => 'Alumni',
			'username' => 'Username',
			'password' => 'Password',
			'ctime' => 'Ctime',
			'status' => 'Status',
			'is_del' => 'Is Del',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);
		$criteria->compare('alumni_id',$this->alumni_id,true);
		$criteria->compare('username',$this->username,true);
		$criteria->compare('password',$this->password,true);
		$criteria->compare('ctime',$this->ctime,true);
		$criteria->compare('status',$this->status,true);
		$criteria->compare('is_del',$this->is_del,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}